package com.wfit.service.impl;


import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wfit.context.UserContext;
import com.wfit.dto.CartDto;
import com.wfit.mapper.AddressMapper;
import com.wfit.mapper.CartMapper;
import com.wfit.po.Address;
import com.wfit.po.Cart;
import com.wfit.po.Commodity;
import com.wfit.result.Result;
import com.wfit.service.AddressService;
import com.wfit.service.CartService;
import com.wfit.service.CommodityService;
import com.wfit.vo.CartVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;


@Service
public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address> implements AddressService {

    @Override
    public Result getlist() {
        Long user = UserContext.getUser();
        List<Address> list = lambdaQuery().eq(Address::getUId, UserContext.getUser()).list();
        list = list.stream().sorted(new Comparator<Address>() {
            @Override
            public int compare(Address o1, Address o2) {
                return o1.getSort() - o2.getSort();
            }
        }).collect(Collectors.toList());
        return Result.success(list);
    }


}



